import React, {useContext,useEffect,useState} from 'react';
import {Button, Divider} from "antd";
import {connect} from 'react-redux';
import Actions from '../../store/action';
const  ReduxStudy = function (props) {
    const {up,down,vote_up,vote_down} = props;
    return (
        <>
            <div className={'container'}>
                <h2>React是很棒的框架</h2>
                <div>
                    {up+down}
                </div>
            </div>
            <div>
                <div>
                    赞同票数:{up}
                </div>
                <div>
                    反对票数:{down}
                </div>
            </div>
            <Divider/>
            <Button onClick={vote_up}>
                投赞同票
            </Button>

            <Button onClick={vote_down}>
                投反对票
            </Button>
        </>
    )

};

const wait = ()=>new Promise(resolve => setTimeout(resolve, 1000));

//connect(公共状态,派发事件)
// export default connect(state=>state.vote,Actions.vote)(ReduxStudy);
export default connect(state=>state.vote,Actions.vote)(ReduxStudy);